package com.th.cash.th2.product

import android.content.Context
import com.lxj.xpopup.core.CenterPopupView
import com.th.resmodel.R
import com.th.resmodel.databinding.PopupUserExitBinding
import com.th.resmodel.databinding.PopupUserRetentionBinding

class UserRetentionPopup(context: Context, val type: Int) : CenterPopupView(context) {

    var clickListener: ((Boolean) -> Unit?)? = null

    override fun getImplLayoutId(): Int {
        return R.layout.popup_user_retention
    }

    override fun onCreate() {
        super.onCreate()

        val bind = PopupUserRetentionBinding.bind(popupImplView)

        bind.run {

            when (type) {
                1 -> {
                    ivTop.setImageResource(R.mipmap.img_55)
                    tvUserTitle.text = context.getString(R.string.retention_1)
                }

                2 -> {
                    ivTop.setImageResource(R.mipmap.img_56)
                    tvUserTitle.text = context.getString(R.string.retention_2)
                }

                3 -> {
                    ivTop.setImageResource(R.mipmap.img_57)
                    tvUserTitle.text = context.getString(R.string.retention_3)
                }

                4 -> {
                    ivTop.setImageResource(R.mipmap.img_58)
                    tvUserTitle.text = context.getString(R.string.retention_4)
                }
            }


            tvSubmit1.setOnClickListener {
                dismiss()
                clickListener?.invoke(false)
            }

            tvSubmit2.setOnClickListener {
                dismiss()
                clickListener?.invoke(true)
            }

        }

    }


}